package apiday01String;

import java.util.Scanner;

public class captcha {
    public static void main(String[] args) {

        String a1;
        String a2;
        do {
        String a="QWERTYUIOPASDFGHJKLZXCVBNM0123456789mnbvcxzlkjhgfdsaopiuytrewq";

        String code="";

        for (int i=0;i<4;i++){
            int index=(int)(Math.random()*a.length());
            char c=a.charAt(index);
            code+=c;
        }
        Scanner sca = new Scanner(System.in);
        System.out.println("验证码为"+code);
        System.out.println("请根据以上的验证码输入");
        String input= sca.next();
          a1=code.toLowerCase();
          a2=input.toLowerCase();

          if (a1.equals(a2)){

              break;
          }else{
              System.out.println("输入错误");
          }

            System.out.println("请重新输入");




          }while (true);
        System.out.println("输入正确");
    }
}
